package com.jeff.tianti.cms.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jeff.tianti.common.entity.BaseEntity;
import com.jeff.tianti.common.util.DateUtils;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Table(name = "resume")//发布简历表
@JsonIgnoreProperties(value={"columnInfo","hibernateLazyInitializer","handler","fieldHandler"})
public class Resume extends BaseEntity {

    private static final long serialVersionUID = -5102241269833494278L;

    @Column(name = "uid")//用户id
    private String uid;
    private String jobType;
    private ColumnInfo columnInfo;
    private String columnInfoName;
    private String jobTypeName;
    @Column(name = "area_id")//地区id    工作地点
    private Integer areaId;
    @Column(name = "provinces")//省市区
    private String provinces;
    @Column(name = "longitud", precision = 10, scale = 6)//经度
    private BigDecimal longitud;
    @Column(name = "latitude",precision = 10,scale = 6)//纬度
    private BigDecimal latitude;
    @Column(name = "money_min")//每月薪资    最低
    private String moneyMin;
    @Column(name = "money_max")//每月薪资    最高
    private String moneyMax;
    @Column(name = "state")//0->讲好   1->面议
    private String state;
    @Column(name = "icon_url")//头像
    private String iconUrl;
    @Column(name = "icon_file")//头像图片file路径
    private String iconFile;
    @Column(name = "name")//姓名
    private String name;
    @Column(name = "gender")//性别
    private String gender;
    @Column(name = "native_place")//籍贯
    private String nativePlace;
    @Column(name = "work_experience")// 工作经验  0->一年以下 1->1-2年 2->3-5年 3->6-7年 4->8-10年 5->10-15年 6->15年以上
    private String workExperience;
    private String workExperienceName;
    @Column(name = "education_background")//学历要求 0->高中 1->技校 2->中专 3->大专 4->本科 5->硕士 6->博士
    private String educationBackground;
    private String educationBackgroundName;



    public String getColumnInfoName() {
        if (columnInfo != null) {
            return columnInfo.getName();
        }
        return "";
    }

    public void setColumnInfoName(String columnInfoName) {
        this.columnInfoName = columnInfoName;
    }

    @Column(name = "birthday")//出生日期
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date birthday;
    @Column(name = "phone")//联系电话
    private String phone;
    @Column(name = "e_mail")//联系邮箱
    private String eMail;
    @Column(name = "self_introduction")//个人介绍
    private String selfIntroduction;
    @Column(name = "phone_show")//手机号码 / 邮箱 0->公开  1->隐藏
    private String phoneShow;
    @Column(name = "resume_show")//简历状态   0->公开  1->隐藏
    private String resumeShow;
    @Column(name = "scope_show")//简历可见范围  0->所有企业  1->仅投递企业
    private String scopeShow;
    private String updateDateString;
    @Transient
    public String getWorkExperienceName() {
//        工作经验  0->一年以下 1->1-2年 2->3-5年 3->6-7年 4->8-10年 5->10-15年 6->15年以上
        if (StringUtils.isBlank(workExperience)) {
            return "";
        }
        return "0".equals(workExperience) ? "一年以下" : "1".equals(workExperience) ? "1-2年" : "2".equals(workExperience) ? "3-5年" : "3".equals(workExperience) ? "6-7年" : "4".equals(workExperience) ? "8-10年" : "5".equals(workExperience) ? "10-15年" : "6".equals(workExperience) ? "15年以上" : "";
    }
    public void setWorkExperienceName(String workExperienceName) {
        this.workExperienceName = workExperienceName;
    }
    @Transient
    public String getEducationBackgroundName() {
       //学历要求 0->高中 1->技校 2->中专 3->大专 4->本科 5->硕士 6->博士
        if (StringUtils.isBlank(educationBackground)) {
            return "";
        }
        return "0".equals(workExperience) ? "高中" : "1".equals(workExperience) ? "技校" : "2".equals(workExperience) ? "中专" : "3".equals(workExperience) ? "大专" : "4".equals(workExperience) ? "本科" : "5".equals(workExperience) ? "硕士" : "6".equals(workExperience) ? "博士" : "";
    }

    public void setEducationBackgroundName(String educationBackgroundName) {
        this.educationBackgroundName = educationBackgroundName;
    }

    public String getUpdateDateString() {
        if (updateDate != null) {
            return DateUtils.dateToString(updateDate, " yyyy-MM-dd HH:mm ");
        }
        return "";
    }

    public void setUpdateDateString(String updateDateString) {
        this.updateDateString = updateDateString;
    }

    public String getJobTypeName() {
        if (columnInfo != null) {
            return columnInfo.getName();
        }
        return "";
    }

    public void setJobTypeName(String jobTypeName) {
        this.jobTypeName = jobTypeName;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid == null ? null : uid.trim();
    }

    @Column(name = "job_type")//cms_column_info职位类别
    public String getJobType() {
        return jobType;
    }

    public void setJobType(String jobType) {
        this.jobType = jobType == null ? null : jobType.trim();

    }

    @ManyToOne(optional = false)
    @JoinColumn(name = "job_type",updatable = false,insertable = false)
    public ColumnInfo getColumnInfo() {
        return columnInfo;
    }

    public void setColumnInfo(ColumnInfo columnInfo) {
        this.columnInfo = columnInfo;
    }

    public Integer getAreaId() {
        return areaId;
    }

    public void setAreaId(Integer areaId) {
        this.areaId = areaId;
    }

    public String getProvinces() {
        return provinces;
    }

    public void setProvinces(String provinces) {
        this.provinces = provinces == null ? null : provinces.trim();
    }

    public BigDecimal getLongitud() {
        return longitud;
    }

    public void setLongitud(BigDecimal longitud) {
        this.longitud = longitud;
    }

    public BigDecimal getLatitude() {
        return latitude;
    }

    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }

    public String getMoneyMin() {
        return moneyMin;
    }

    public void setMoneyMin(String moneyMin) {
        this.moneyMin = moneyMin;
    }

    public String getMoneyMax() {
        return moneyMax;
    }

    public void setMoneyMax(String moneyMax) {
        this.moneyMax = moneyMax;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getIconUrl() {
        return iconUrl;
    }

    public void setIconUrl(String iconUrl) {
        this.iconUrl = iconUrl == null ? null : iconUrl.trim();
    }

    public String getIconFile() {
        return iconFile;
    }

    public void setIconFile(String iconFile) {
        this.iconFile = iconFile == null ? null : iconFile.trim();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender == null ? null : gender.trim();
    }

    public String getNativePlace() {
        return nativePlace;
    }

    public void setNativePlace(String nativePlace) {
        this.nativePlace = nativePlace == null ? null : nativePlace.trim();
    }

    public String getWorkExperience() {
        return workExperience;
    }

    public void setWorkExperience(String workExperience) {
        this.workExperience = workExperience == null ? null : workExperience.trim();
    }

    public String getEducationBackground() {
        return educationBackground;
    }

    public void setEducationBackground(String educationBackground) {
        this.educationBackground = educationBackground == null ? null : educationBackground.trim();
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone == null ? null : phone.trim();
    }

    public String geteMail() {
        return eMail;
    }

    public void seteMail(String eMail) {
        this.eMail = eMail == null ? null : eMail.trim();
    }

    public String getSelfIntroduction() {
        return selfIntroduction;
    }

    public void setSelfIntroduction(String selfIntroduction) {
        this.selfIntroduction = selfIntroduction == null ? null : selfIntroduction.trim();
    }

    public String getPhoneShow() {
        return phoneShow;
    }

    public void setPhoneShow(String phoneShow) {
        this.phoneShow = phoneShow == null ? null : phoneShow.trim();
    }

    public String getResumeShow() {
        return resumeShow;
    }

    public void setResumeShow(String resumeShow) {
        this.resumeShow = resumeShow == null ? null : resumeShow.trim();
    }

    public String getScopeShow() {
        return scopeShow;
    }

    public void setScopeShow(String scopeShow) {
        this.scopeShow = scopeShow == null ? null : scopeShow.trim();
    }

}